#ifndef __GLESWINDOW_H__
#define __GLESWINDOW_H__

#define MAP_STATUS_CURSOR	(0)
#define MAP_STATUS_DEMO		(1)


class CRender
{
public:

	CRender()
	{
		m_mapData = NULL;
		m_pRoute = NULL;

		m_centerPt.x = DB_RANGE_X/2;
		m_centerPt.y = DB_RANGE_Y/2;
		m_fscale = 1.0f;
		m_cStatus = MAP_STATUS_CURSOR;
		m_iDemoPointIndex= 0;
	}

	virtual	~CRender()
	{
	}

	bool Initialize(HANDLE hwnd, int iWidth, int iHeight);

	void UnInitialize();

	void DoRender(void* pvRenderBuff);

	void ExecuteCmd(CommandType cmd);

	void SetMapData(MapData *pMapData)
	{
		m_mapData = pMapData;
		makeDisplayData();
	}

	void SetRoute(Route	*pRoute)
	{
		m_pRoute = pRoute;
		makeDisplayData();
	}

	void SetQuery(Query *pQuery)
	{
		m_pQuery = pQuery;
	}

	void GetObjectCnt(int* piCnt)
	{
		*piCnt = m_vecObjectInfos.size();
	}

	void GetObjectPosition(ObjectInfo* pstObjInfo)
	{
		if(m_vecObjectInfos.size()!=0)
		{
			memcpy(pstObjInfo, &m_vecObjectInfos[0], sizeof(ObjectInfo)*m_vecObjectInfos.size());
		}
	}

	void GetSplitNodeCnt(int* piSnCnt)
	{
		*piSnCnt = m_vecSplidNode.size();

	}

	void GetSearchObjCnt(int* piObjCnt)
	{
		*piObjCnt = m_vecSearchPoint.size();
	}

	void GetSplitNodeInfo(SplitNodeInfo* pstSnInfo)
	{
		if(m_vecSplidNode.size()!=0)
		{
			memcpy(pstSnInfo, &m_vecSplidNode[0], sizeof(SplitNodeInfo)*m_vecSplidNode.size());
		}
	}

	void GetSearchObjInfo(ObjectInfo* pstObjInfo)
	{
		if(m_vecSearchPoint.size()!=0)
		{
			memcpy(pstObjInfo, &m_vecSearchPoint[0], sizeof(ObjectInfo)*m_vecSearchPoint.size());
		}
	}

	void GetMapCenterPoint(float* fCenterX, float* fCenterY)
	{
		*fCenterX = m_centerPt.x;
		*fCenterY = m_centerPt.y;
	}

	void GetMapScale(float* fScale)
	{
		*fScale = m_fscale;
	}
	
	void SetSearchType(SearchType type)
	{
		m_SearchType = type;
	}

private:

	void moveUFOToNextPoint();

	void makeDisplayData();

	void drawCursor();

	void drawParcelBorder(ParcelMng_t* pstParcel);

	vector<PointF_t>		m_vecLines;
	vector<PointF_t>		m_vecRoute;
	vector<PointF_t>		m_vecObject;
	vector<PointF_t>		m_vecUFOPos;
	
	// for gui
	vector<ObjectInfo>			m_vecObjectInfos;
	vector<ObjectInfo>			m_vecSearchPoint;
	vector<SplitNodeInfo>		m_vecSplidNode;

	EGLDisplay			m_eglDisplay;
	EGLConfig			m_eglConfig;
	EGLSurface			m_eglSurface;
	EGLContext			m_eglContext;
	NativeWindowType	m_eglWindow;
	EGLint				m_pi32ConfigAttribs[128];

	int					m_iWidth;
	int					m_iHeight;


	PointF_t			m_centerPt;
	float				m_fscale;
	char				m_cStatus;
	int					m_iDemoPointIndex;

	MapData				*m_mapData;
	Query				*m_pQuery;
	Route				*m_pRoute;

	SearchType			m_SearchType;

};

#endif
